@import "../../themes/ionic.globals.ios";

// iOS Radio
// --------------------------------------------------

/// @prop - Color of the checked radio
$radio-ios-color-on:                  color($colors-ios, primary) !default;

/// @prop - Width of the radio icon
$radio-ios-icon-width:                16px !default;

/// @prop - Height of the radio icon
$radio-ios-icon-height:               21px !default;

/// @prop - Border width of the radio icon
$radio-ios-icon-border-width:         2px !default;

/// @prop - Border style of the radio icon
$radio-ios-icon-border-style:         solid !default;

/// @prop - Opacity of the disabled radio
$radio-ios-disabled-opacity:          .3 !default;

// deprecated
$radio-ios-item-left-margin:          null !default;

/// @prop - Margin top of the item-start in a radio
$radio-ios-item-start-margin-top:     8px !default;

/// @prop - Margin end of the item-start in a radio
$radio-ios-item-start-margin-end:     21px !default;

/// @prop - Margin bottom of the item-start in a radio
$radio-ios-item-start-margin-bottom:  8px !default;

/// @prop - Margin start of the item-start in a radio
$radio-ios-item-start-margin-start:   3px !default;

// deprecated
$radio-ios-item-right-margin:         null !default;

/// @prop - Margin top of the item-end in a radio
$radio-ios-item-end-margin-top:       $item-ios-padding-media-top !default;

/// @prop - Margin end of the item-end in a radio
$radio-ios-item-end-margin-end:       11px !default;

/// @prop - Margin bottom of the item-end in a radio
$radio-ios-item-end-margin-bottom:    $item-ios-padding-media-bottom !default;

/// @prop - Margin start of the item-end in a radio
$radio-ios-item-end-margin-start:     ($item-ios-padding-start / 2) !default;


.radio-ios {
  position: relative;
  display: inline-block;
}


// iOS Radio Circle: Unchecked
// -----------------------------------------

.radio-ios .radio-icon {
  position: relative;
  display: block;

  width: $radio-ios-icon-width;
  height: $radio-ios-icon-height;
}


// iOS Radio Checkmark: Checked
// -----------------------------------------

.radio-ios .radio-checked .radio-inner {
  @include position(4px, null, null, 7px);

  position: absolute;

  width: 5px;
  height: 12px;

  border-width: $radio-ios-icon-border-width;
  border-top-width: 0;
  border-left-width: 0;
  border-style: $radio-ios-icon-border-style;
  border-color: $radio-ios-color-on;
  transform: rotate(45deg);
}


// iOS Radio: Disabled
// -----------------------------------------

.radio-ios.radio-disabled,
.item-ios.item-radio-disabled ion-label {
  opacity: $radio-ios-disabled-opacity;

  pointer-events: none;
}


// iOS Radio Within An Item
// -----------------------------------------

.item-ios .radio-ios {
  position: static;
  display: block;

  @include deprecated-variable(margin, $radio-ios-item-right-margin) {
    @include margin($radio-ios-item-end-margin-top, $radio-ios-item-end-margin-end, $radio-ios-item-end-margin-bottom, $radio-ios-item-end-margin-start);
  }

  &[item-left], // deprecated
  &[item-start] {
    @include deprecated-variable(margin, $radio-ios-item-left-margin) {
      @include margin($radio-ios-item-start-margin-top, $radio-ios-item-start-margin-end, $radio-ios-item-start-margin-bottom, $radio-ios-item-start-margin-start);
    }
  }
}

.item-radio.item-ios ion-label {
  @include margin-horizontal(0, null);
}


// iOS Radio Item Label: Checked
// -----------------------------------------

.item-radio-checked.item-ios ion-label {
  color: $radio-ios-color-on;
}


// iOS Radio Color Mixin
// --------------------------------------------------

@mixin radio-theme-ios($color-name, $color-base) {

  .item-radio-ios-#{$color-name}.item-radio-checked ion-label {
    color: $color-base;
  }

  .radio-ios-#{$color-name} .radio-checked {
    color: $color-base;
  }

  .radio-ios-#{$color-name} .radio-checked  .radio-inner {
    border-color: $color-base;
  }

}


// Generate iOS Radio Colors
// --------------------------------------------------

@each $color-name, $color-base, $color-contrast in get-colors($colors-ios) {
  @include radio-theme-ios($color-name, $color-base);
}
